home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 March / PC Answers CD-ROM 5 (Future Publishing) (March 1995).iso / library / olddiscs / iss12 / experts.exe / CDFIND.BAS next >
Encoding:
BASIC Source File  |  1994-11-03  |  3.2 KB  |  107 lines

  1. DECLARE FUNCTION GetMSCDEX% ()
  2. DEFINT A-Z
  3.  
  4. ' Definitions for the register structure passed to QINT
  5.  
  6. TYPE Registers
  7.      ax    AS INTEGER
  8.      bx    AS INTEGER
  9.      cx    AS INTEGER
  10.      dx    AS INTEGER
  11.      bp    AS INTEGER
  12.      si    AS INTEGER
  13.      di    AS INTEGER
  14.      ds    AS INTEGER
  15.      es    AS INTEGER
  16.      flags AS INTEGER
  17. END TYPE
  18.  
  19. ' Public routines
  20.  
  21. DECLARE FUNCTION GetDriveCount ()
  22. DECLARE FUNCTION GotMSCDEX ()
  23. DECLARE FUNCTION IsCDROMDrive (drive%)
  24.  
  25. COMMON SHARED regs AS Registers
  26. DIM SHARED code(55)                   'array to hold QINT code
  27.  
  28. COLOR 15, 1
  29. CLS
  30. DEF SEG = VARSEG(code(0))             ' point to QINT code
  31. BLOAD "QINT.OVL", 0                   ' load QINT code
  32.  
  33. PRINT : PRINT
  34. IF GetMSCDEX = 0 THEN
  35.     PRINT "Microsoft CD-ROM Extensions not loaded !"
  36.     END
  37. END IF
  38.  
  39. FOR drv = 0 TO GetDriveCount - 1
  40.     PRINT CHR$(9) + CHR$(drv + ASC("A")) + ": ";
  41.     IF IsCDROMDrive(drv) THEN
  42.     PRINT "This is a CD-ROM drive"
  43.     ELSE
  44.     PRINT "This is a plain-vanilla drive"
  45.     END IF
  46. NEXT
  47.  
  48.  
  49. '----------------------------------------------------------------------------
  50. '       Name:           GetDriveCount
  51. '       Purpose:        Return number of logical drives known to DOS
  52. '----------------------------------------------------------------------------
  53. FUNCTION GetDriveCount
  54.  
  55.     ' Call interrupt $19 to get current drive letter
  56.     
  57.     regs.ax = &H1900                        ' specify get drive letter
  58.     DEF SEG = VARSEG(code(0))               ' point to QINT code
  59.     CALL absolute(&H21, regs, 0)            ' get drive number in AL
  60.  
  61.     ' Now set drive letter to current, in order to get drive count
  62.  
  63.     regs.dx = regs.ax
  64.     regs.ax = &HE00
  65.     CALL absolute(&H21, regs, 0)            ' get drive count in AL
  66.     GetDriveCount = regs.ax AND 255
  67.     DEF SEG
  68. END FUNCTION
  69.  
  70. '----------------------------------------------------------------------------
  71. '       Name:           GetMSCDEX
  72. '       Purpose:        Determine whether or not MSCDEX is loaded
  73. '----------------------------------------------------------------------------
  74. FUNCTION GetMSCDEX
  75.     ' Call multiplex $2F/1500 to see if MSCDEX present
  76.        
  77.     regs.ax = &H1500                        ' specify install check
  78.     regs.bx = 0                             ' pre-init to zero
  79.     DEF SEG = VARSEG(code(0))               ' point to QINT code
  80.     CALL absolute(&H2F, regs, 0)            ' get result in BX register
  81.  
  82.     GetMSCDEX = regs.bx AND 255
  83.     DEF SEG
  84. END FUNCTION
  85.  
  86. '----------------------------------------------------------------------------
  87. '       Name:           IsCDROMDrive
  88. '       Purpose:        Determine if specified drive is a CD-ROM
  89. '----------------------------------------------------------------------------
  90. FUNCTION IsCDROMDrive (drive%)
  91.     ' Call multiplex $2F/150B to check drive status
  92.       
  93.     regs.ax = &H150B                        ' specify drive check
  94.     regs.cx = drive%                        ' Cx = drive number
  95.     DEF SEG = VARSEG(code(0))               ' point to QINT code
  96.     CALL absolute(&H2F, regs, 0)            ' get result in AX register
  97.  
  98.     IF regs.ax <> 0 THEN
  99.     IsCDROMDrive = 1
  100.     ELSE
  101.     IsCDROMDrive = 0
  102.     END IF
  103.    
  104.     DEF SEG
  105. END FUNCTION
  106.  
  107.